﻿using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wintellect.PowerCollections;

namespace ImaginaryNumber
{
    class PriorityQueue<T>: IEnumerable
    {
        OrderedBag<T> dataCollectior;
        public PriorityQueue() 
        {
            dataCollectior = new OrderedBag<T>();
        }

        public IEnumerator GetEnumerator()
        {
            foreach (var item in dataCollectior) 
            {
                yield return item;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        public int Count
        {
            get
            {
                return dataCollectior.Count;
            }

            private set
            {

            }
        }

        public void Enqueue(T item) 
        {
            dataCollectior.Add(item);
        }

        public T Dequeue() 
        {
            T item = dataCollectior.GetFirst();
            dataCollectior.RemoveFirst();
            return item;
        }
    }
}
